package cn.sc.allinpay.allfavour.business.paymentresult;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import cn.pai.mvp.callback.MpCallBack;
import cn.sc.allinpay.allfavour.base.connect.http.AppRequest;
import cn.sc.allinpay.allfavour.base.connect.http.RequestManager;
import cn.sc.allinpay.allfavour.base.model.BaseModel;
import cn.sc.allinpay.allfavour.business.common.data.SpOrderInfo;

/**
 * 去支付
 * author：pany
 * on 2017/12/5 14:44
 */
public class PaymentResultModel extends BaseModel {
    /**
     * 扫码结果查询
     *
     */
    public void spOrderInfo(final String outOrderNo, final MpCallBack<SpOrderInfo, String> mpCallBack) {
        RequestManager.spOrderInfo(outOrderNo, new AppRequest.PosRequestCall() {
            @Override
            protected void onSuccess(JSONObject response) {
                SpOrderInfo orderInfo = JSON.parseObject(response.getString("data"), SpOrderInfo.class);
                mpCallBack.onSuccess(orderInfo);
            }

            @Override
            public void onFailure(JSONObject response, String message) {
                mpCallBack.onFailure(response != null ? response.toString() : null, message);
            }
        });
    }

    public void payNotify(final String order_id, final String trans_way, final String traxstatus, final String trans_time, final String c_amount, final String a_amount, final String transactionNumber, final MpCallBack<JSONObject, String> mpCallBack) {
        RequestManager.payNotify(order_id, trans_way, traxstatus, trans_time, c_amount, a_amount, transactionNumber, new AppRequest.RequestCall() {
            @Override
            protected void onSuccess(JSONObject response) {
                mpCallBack.onSuccess(response);
            }

            @Override
            public void onFailure(JSONObject response, String message) {
                mpCallBack.onFailure(response != null ? response.toString() : null, message);
            }
        });
    }
}
